/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-03-13     desktop       the first version
 */
#include <rtthread.h>
#include <rtdevice.h>

#define DBG_TAG "pwm_test.c"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

#define PWM_DEV_NAME "pwm2" /* PWM 设 备 名 称 */
#define PWM_DEV_CHANNEL 1
struct rt_device_pwm *pwm_dev; /* PWM 设 备 句 柄 */

static int pwm_test(void)
{
    rt_uint32_t period , pulse;
    period = 200000;
    pulse = 100000;
    pwm_dev = (struct rt_device_pwm*)rt_device_find(PWM_DEV_NAME); //查找PWM设备

    //配置PWM
    rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, period, pulse);

    if (rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL) == RT_EOK)
    {
        LOG_D("PWM Init is ok \t\n");
        return RT_EOK;
    }

    return RT_EOK;

}


MSH_CMD_EXPORT(pwm_test, pwm device sample);
